package org.csu.demopetstore.Service;

import org.csu.demopetstore.Persistence.CategoryMapper;
import org.csu.demopetstore.Persistence.ItemMapper;
import org.csu.demopetstore.Persistence.ProductMapper;
import org.csu.demopetstore.entity.Category;
import org.csu.demopetstore.entity.Item;
import org.csu.demopetstore.entity.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategortService {

    @Autowired
    private CategoryMapper categoryMapper;
    @Autowired
    private ProductMapper productMapper;
    @Autowired
    private ItemMapper itemMapper;

    //Category
    public List<Category> getCategoryList(){
        return categoryMapper.getCategoryList();
    }

    public Category getCategory(String categoryId){
        return categoryMapper.getCategory(categoryId);
    }

    //Product
    public Product getProduct(String productId){
        return productMapper.getProduct(productId);
    }
    public List<Product> getProductList(String categoryId){
        return productMapper.getProductList(categoryId);
    }

    //Item
    public List<Item> getItemList(String productId){
        return itemMapper.getItemList(productId);
    }
    public Item getItem(String itemId){
        return itemMapper.getItem(itemId);
    }

    public List<Category> searchCategory(String keyword){
        return categoryMapper.searchCategory(keyword);
    }

    public List<Product> searchProduct(String keyword){
        return productMapper.searchProduct(keyword);
    }
}
